﻿@{
    ViewBag.Title = "CreateSelfInfo";
    Layout = "~/Views/Shared/_CreateLayout.cshtml";
}
@model SelfInfo.Models.SELFINFO
<h2>Create SelfInfo</h2>

@using (Html.BeginForm("Create", "SelfInfo", FormMethod.Post, new { @class = "form-horizontal", role="form" }))
{
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>SELFINFO</legend>
        
        <div class='form-group'>
            <div class="col-sm-2 control-label">
                @Html.LabelFor(model => model.PIECEID)
            </div>
            @*@Html.DropDownList("PIECEID") *@
            
            <div class="col-sm-4">
                @Html.DropDownList("PIECETYPE", (SelectList)ViewData["PIECETYPE"], "SELECT", new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.PIECEID)       
            </div>
            <div  class="col-sm-4">
                <span id='peice_container'>
                </span>
            </div>
        </div>
        <div class='form-group'>
            <div class="col-sm-2 control-label">
                @Html.LabelFor(model => model.TODAY)
            </div>
            <div class="col-sm-4">
                @Html.EditorFor(model => model.TODAY, "DataPicker")
                @Html.ValidationMessageFor(model => model.TODAY)
            </div>
        </div>
        
        <div class='form-group'>
            <div class="col-sm-2 control-label">
                @Html.LabelFor(model => model.SCORE)
            </div>
            <div class="col-sm-4">
                @*@Html.EditorFor(model => model.SCORE)*@
                @Html.TextBoxFor(x => x.SCORE, new { @class = "form-control" })
            </div>
        </div>

        <div class='form-group'>
            <div class="col-sm-2 control-label">
                @Html.LabelFor(model => model.BRIEF)
            </div>
            <div class="col-sm-4">
                @Html.TextBoxFor(x => x.BRIEF, new { @class = "form-control" })
            </div>
        </div>

        <div class='form-group'>
            <div class="col-sm-2 control-label">
                @Html.LabelFor(model => model.COMMENT)
            </div>
            <div class="col-sm-4">
                @Html.TextBoxFor(x => x.COMMENT, new { @class = "form-control" })
            </div>
        </div>
        
        <div class='form-group'>
            <div class='col-sm-6'>
               
                @*@Html.ActionLink("Back to List", "Index", new { }, new { @class = "btn btn-default  pull-right" })*@
                
                <button type="submit" class="btn btn-primary pull-right">Create</button>
            </div>
        </div>
    </fieldset>
}

<script>
    $(document).ready(function () {
        $('#PIECETYPE').change(function () {
            var type = $(this).children('option:selected').val();
            $.get("/selfinfo/selfinfo/GetPieceByType", { id: type }, function (data) {
                console.log(data);
                var $d = $(data.trim());
                $d.addClass('form-control');
                if (data) {
                    $('#peice_container').html($d);
                } else {
                    $('#peice_container').html("");
                }
            });
        })
    });

</script>